#ifndef QLIB_COMPONENTWINDOW_H
#define QLIB_COMPONENTWINDOW_H

#include <QtCore/qhash.h>
#include <QtGui/qsplitter.h>

QT_FORWARD_DECLARE_CLASS(QButtonGroup)
QT_FORWARD_DECLARE_CLASS(QComboBox)
QT_FORWARD_DECLARE_CLASS(QPushButton)
QT_FORWARD_DECLARE_CLASS(QTabWidget)

class QedaComponent;
class LibraryModel;
class ComponentGeneral;

/*struct GeneralTab
{
    QComboBox *library;
};*/

class ComponentWindow : public QSplitter
{
    Q_OBJECT
public:
    explicit ComponentWindow(LibraryModel *libModel, QedaComponent *component, QWidget *parent = 0);
    
    QedaComponent *component() { return m_component; }

protected:
    void closeEvent(QCloseEvent *event);

signals:
    void modified(bool modified);
    
public slots:
    void setModified(bool modifiedFlag = true);
    void apply();
    void restore();

private slots:
    void changeComponentFlags(int componentFlags);
    void updateTabs(int componentFlags);

private:
    QWidget *createGeneralTab();
    QWidget *createSymbolTab();
    QWidget *createPatternTab();

private:
    bool                     m_modified;
    QedaComponent           *m_component;
    LibraryModel            *m_libModel;

    QHash<QString,QWidget*>  m_tabs;
    QPushButton             *m_applyButton;
    QPushButton             *m_restoreButton;
    QTabWidget              *m_propertiesTab;
    QWidget                 *m_symbolPreview;
    QWidget                 *m_patternPreview;
    QSplitter               *m_previewSplitter;

    ComponentGeneral        *m_general;
    QButtonGroup            *m_symbolPattern;
    
};

#endif // QLIB_COMPONENTWINDOW_H
